package kr.or.javacafe.common.util;

public class SplitUtil {

    public static int endPage(int currentPage, int countPerPage, int totalNo) 
    {
        int extra = totalNo % countPerPage;
        
        if ( extra > 0 ){           
            return (totalNo - extra )/countPerPage + 1;
        } else {
            return totalNo/countPerPage;
        }
    }
    
    
    public static String linkURI(String contextPath, int countPerPage, int endPage)
    {
    	StringBuffer sb = new StringBuffer();
    	
    	for (int i=0; i<endPage; i++)
    	{
    		/*
			sb.append("<a href=\"");
			sb.append(contextPath);
			sb.append("/board/board.do?currentPage=");
			sb.append(i+1);
			sb.append("&countPerPage=");
			sb.append(countPerPage);
			sb.append("\">");
			sb.append(i+1);
			sb.append("</a>");
			*/
    		sb.append(i+1);
    		
			if( i < (endPage-1) ){
				sb.append("&nbsp");
			}
    	}
    	
    	return sb.toString();
    }
    
    
}
